import request from '@/utils/request'

// 查询采购订单列表
export function listPurchaseOrder(query) {
  return request({
    url: '/mes/pro/po/list?pageNum='+query.pageNum+'&pageSize='+query.pageSize,
    // url: '/mes/pro/po/listConfirmed?pageNum='+query.pageNum+'&pageSize='+query.pageSize,
    method: 'post',
    data: query
  })
}

// 修改采购订单列表
export function updatePurchaseOrder(data) {
  return request({
    url: '/mes/pro/po/edit',
    method: 'put',
    data
  })
}

// 查询采购订单列表详情
export function detailPurchaseOrder(id, params) {
  return request({
    url: '/mes/pro/po/detail/' + id,
    method: 'get',
    params
  })
}
// 根据采购订单号获取采购订单详情
export function getPurchaseOrderByCode(poCode) {
  return request({
    url: '/mes/pro/po/getByCode/' + poCode,
    method: 'get'
  })
}

// 获取采购订单的物料明细
export function getPurchaseOrderMaterials(poId) {
  return request({
    url: '/mes/pro/po/materials/' + poId,
    method: 'get'
  })
}

// 删除采购订单列表
export function deletePurchaseOrder(id) {
  return request({
    url: '/mes/pro/po/del/' + id,
    method: 'delete',
  })
}

// 新增采购订单列表
export function addPurchaseOrder(data) {
  return request({
    url: '/mes/pro/po/add',
    method: 'post',
    data
  })
}

// 新增采购订单列表
export function orderList(data) {
  return request({
    url: '/mes/pro/po/line/edit',
    method: 'put'
  })
}

// 新增采购订单列表
export function getListConfirmed(data) {
  return request({
    url: '/mes/pro/po/listConfirmed?pageNum='+data.pageNum+'&pageSize='+data.pageSize,
    method: 'post',
    data
  })
}